package com.ltkj.baseplatform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.baseplatform.domain.WuserCollect;
import com.ltkj.baseplatform.service.IWuserCollectService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 用户收藏Controller
 * 
 * @author chenzeen
 * @date 2023-08-31
 */
@Api(tags = "用户收藏")
@RestController
@RequestMapping("/collect")
public class WuserCollectController extends BaseController
{
    @Autowired
    private IWuserCollectService wuserCollectService;

    /**
     * 查询用户收藏列表
     */
    @ApiOperation("查询用户收藏列表")
    @RequiresPermissions("baseplatform:collect:list")
    @GetMapping("/list")
    public TableDataInfo list(WuserCollect wuserCollect)
    {
        startPage();
        List<WuserCollect> list = wuserCollectService.selectWuserCollectList(wuserCollect);
        return getDataTable(list);
    }

    /**
     * 导出用户收藏列表
     */
    @ApiOperation("导出用户收藏列表")
    @RequiresPermissions("baseplatform:collect:export")
    @Log(title = "用户收藏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WuserCollect wuserCollect)
    {
        List<WuserCollect> list = wuserCollectService.selectWuserCollectList(wuserCollect);
        ExcelUtil<WuserCollect> util = new ExcelUtil<WuserCollect>(WuserCollect.class);
        util.exportExcel(response, list, "用户收藏数据");
    }

    /**
     * 获取用户收藏详细信息
     */
    @ApiOperation("获取用户收藏详细信息")
    @RequiresPermissions("baseplatform:collect:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wuserCollectService.selectWuserCollectById(id));
    }

    /**
     * 新增用户收藏
     */
    @ApiOperation("新增用户收藏")
    @RequiresPermissions("baseplatform:collect:add")
    @Log(title = "用户收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WuserCollect wuserCollect)
    {
        return toAjax(wuserCollectService.insertWuserCollect(wuserCollect));
    }

    /**
     * 修改用户收藏
     */
    @ApiOperation("修改用户收藏")
    @RequiresPermissions("baseplatform:collect:edit")
    @Log(title = "用户收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WuserCollect wuserCollect)
    {
        return toAjax(wuserCollectService.updateWuserCollect(wuserCollect));
    }

    /**
     * 删除用户收藏
     */
    @ApiOperation("删除用户收藏")
    @RequiresPermissions("baseplatform:collect:remove")
    @Log(title = "用户收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wuserCollectService.deleteWuserCollectByIds(ids));
    }
}
